/*
 * Copyright 2017-2025 noear.org and authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package labs;

import org.noear.solon.core.event.EventBus;
import org.noear.solon.core.event.EventListener;

/**
 * @author noear 2023/7/23 created
 */
public class EventTest {
    public static void main(String args[]){
        DemoEventListener listener = new DemoEventListener();

        //订阅
        EventBus.subscribe(DemoEvent.class, e -> { System.out.println("fun"); });
        EventBus.subscribe(DemoEvent.class, 2, listener);
        //推送
        EventBus.publish(new DemoEvent());
        //取消订阅
        EventBus.unsubscribe(listener);

        System.out.println("ok");

    }

    public static class DemoEventListener implements EventListener<DemoEvent>{
        @Override
        public void onEvent(DemoEvent demoEvent) throws Throwable {
            System.out.println("clz");
        }
    }

    public static class DemoEvent {

    }
}
